import 'package:flutter/material.dart';
import 'package:shopping_cart/signup.dart';
import 'package:shopping_cart/utils/CustomBorder.dart';
import 'package:shopping_cart/utils/CustomColors.dart';
import 'package:shopping_cart/utils/CustomTextStyle.dart';
import 'package:shopping_cart/utils/CustomUtils.dart';

import 'home.dart';

class Login extends StatefulWidget {
  @override
  _LoginState createState() => _LoginState();
}

class _LoginState extends State<Login> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      resizeToAvoidBottomInset: false,
      body: Builder(
        builder: (context) {
          return Container(
            width: double.infinity,
            child: Column(
              children: <Widget>[
                Expanded(
                  child: Image(
                    image: AssetImage("images/ic_logo.png"),
                    color: Colors.blue,
                    height: 140,
                    alignment: Alignment.center,
                    width: 200,
                  ),
                  flex: 40,
                ),
                Expanded(
                  child: Container(
                    margin: EdgeInsets.all(16),
                    child: Column(
                      children: <Widget>[
                        TextFormField(
                          decoration: InputDecoration(
                            contentPadding: EdgeInsets.fromLTRB(16, 16, 16, 12),
                            border: CustomBorder.enabledBorder,
                            labelText: "Mobile No. or Email",
                            focusedBorder: CustomBorder.focusBorder,
                            errorBorder: CustomBorder.errorBorder,
                            enabledBorder: CustomBorder.enabledBorder,
                            labelStyle: CustomTextStyle.textFormFieldMedium
                                .copyWith(
                                  fontSize:
                                      MediaQuery.of(context).textScaleFactor *
                                      16,
                                  color: Colors.black,
                                ),
                          ),
                        ),
                        Utils.getSizedBox(height: 20),
                        TextFormField(
                          decoration: InputDecoration(
                            contentPadding: EdgeInsets.fromLTRB(16, 16, 16, 12),
                            border: CustomBorder.enabledBorder,
                            labelText: "Password",
                            focusedBorder: CustomBorder.focusBorder,
                            errorBorder: CustomBorder.errorBorder,
                            enabledBorder: CustomBorder.enabledBorder,
                            labelStyle: CustomTextStyle.textFormFieldMedium
                                .copyWith(
                                  fontSize:
                                      MediaQuery.of(context).textScaleFactor *
                                      16,
                                  color: Colors.black,
                                ),
                          ),
                          obscureText: true,
                        ),
                        Utils.getSizedBox(height: 20),
                        Container(
                          width: double.infinity,
                          child: RaisedButton(
                            onPressed: () {
                              Navigator.pushReplacement(
                                context,
                                new MaterialPageRoute(
                                  builder: (context) => Home(),
                                ),
                              );
                            },
                            child: Text(
                              "LOGIN",
                              style: CustomTextStyle.textFormFieldRegular
                                  .copyWith(color: Colors.white, fontSize: 14),
                            ),
                            color: Colors.blue,
                            textColor: Colors.white,
                            shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.all(
                                Radius.circular(4),
                              ),
                            ),
                          ),
                        ),
                        Utils.getSizedBox(height: 10),
                        Container(
                          alignment: Alignment.centerRight,
                          child: GestureDetector(
                            child: Text(
                              "Forget Password?",
                              style: CustomTextStyle.textFormFieldBold.copyWith(
                                color: Colors.blue,
                                fontSize: 14,
                              ),
                            ),
                          ),
                        ),
                        Utils.getSizedBox(height: 10),
                        Row(
                          children: <Widget>[
                            Expanded(
                              child: Container(
                                color: Colors.grey.shade200,
                                margin: EdgeInsets.only(right: 16),
                                height: 1,
                              ),
                              flex: 40,
                            ),
                            Text(
                              "Or",
                              style: CustomTextStyle.textFormFieldMedium
                                  .copyWith(fontSize: 14),
                            ),
                            Expanded(
                              child: Container(
                                color: Colors.grey.shade200,
                                margin: EdgeInsets.only(left: 16),
                                height: 1,
                              ),
                              flex: 40,
                            ),
                          ],
                        ),
                        Utils.getSizedBox(height: 14),
                        Container(
                          width: double.infinity,
                          child: RaisedButton(
                            onPressed: () {},
                            child: Text(
                              "FACEBOOK LOGIN",
                              style: CustomTextStyle.textFormFieldMedium
                                  .copyWith(color: Colors.white, fontSize: 14),
                            ),
                            color: CustomColors.COLOR_FB,
                            textColor: Colors.white,
                            shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.all(
                                Radius.circular(4),
                              ),
                            ),
                          ),
                        ),
                        Utils.getSizedBox(height: 10),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: <Widget>[
                            Text(
                              "Don't have an account?",
                              style: CustomTextStyle.textFormFieldMedium
                                  .copyWith(fontSize: 14),
                            ),
                            Utils.getSizedBox(width: 4),
                            GestureDetector(
                              child: Text(
                                "Sign Up",
                                style: CustomTextStyle.textFormFieldBold
                                    .copyWith(fontSize: 14, color: Colors.blue),
                              ),
                              onTap: () {
                                Navigator.of(context).push(
                                  new MaterialPageRoute(
                                    builder: (context) => SignUp(),
                                  ),
                                );
                              },
                            ),
                          ],
                        ),
                      ],
                    ),
                  ),
                  flex: 60,
                ),
              ],
            ),
          );
        },
      ),
    );
  }

  RaisedButton({
    required Null Function() onPressed,
    required Text child,
    required Color color,
    required Color textColor,
    required RoundedRectangleBorder shape,
  }) {}
}
